package com.teach.servlet;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.teach.entity.user;
import com.teach.service.UserService;
import com.teach.service.impl.UserServiceImpl;

public class UserListServletindex extends HttpServlet{
	 private UserService userService = new UserServiceImpl();
	 @Override
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		 int current = 1;
			try{
				current = Integer.valueOf(request.getParameter("current"));
			}catch(Exception ex){
			}
			
			int rowMax = 5;
			try{
				rowMax = Integer.valueOf(request.getParameter("rowMax"));
			}catch(Exception ex){
			}
			
			List<user> list = userService.page(current, rowMax);
			request.setAttribute("list", list);
			
			int count=userService.count();
			request.setAttribute("count", count);
			request.getRequestDispatcher("/admin/user-list-index.jsp").forward(request, response);      //注意更改地址
	}
}
